import { configureStore } from "@reduxjs/toolkit";
import {
  useDispatch,
  useSelector,
  type TypedUseSelectorHook,
} from "react-redux";
import detailWindowReducer from "./features/detailWindowSlice";

// 创建 Redux store
const store = configureStore({
  reducer: {
    detailWindow: detailWindowReducer,
  },
  devTools: process.env.NODE_ENV !== "production", // 在非生产环境启用 Redux DevTools
});

// 导出 RootState 和 AppDispatch 类型
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;

// 创建类型化的 hooks
export const useAppDispatch: () => AppDispatch = useDispatch;
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;

export default store;
